<?php defined('SYSPATH') or die();?>
<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>旅小店管理-思途CMS{$coreVersion}</title>
    {template 'stourtravel/public/public_js'}
    {php echo Common::getCss('style.css,base.css,base_new.css'); }
    {php echo Common::getScript("uploadify/jquery.uploadify.min.js,jquery.buttonbox.js,choose.js,DatePicker/WdatePicker.js"); }

</head>
<body style="overflow:hidden">
<table class="content-tab">
    <tr>
        <td width="119px" class="content-lt-td"  valign="top">
            {template 'stourtravel/public/leftnav'}
            <!--左侧内容区-->
        </td>
        <td valign="top" class="content-rt-td" style="overflow:hidden">
            <div class="cfg-header-bar">
                <a href="javascript:;" class="fr btn btn-primary radius mt-6 mr-10" onclick="window.location.reload()">刷新</a>
            </div>
            <div class="cfg-search-bar">
                <span class="select-box fl mt-3 ml-10 w100">
                    <select name="status" class="select">
                        <option value="99">订单状态</option>
                        <option value="0">待确认</option>
                        <option value="1">待支付</option>
                        <option value="2">待消费</option>
                        <option value="3">已关闭</option>
                        <option value="4">已退款</option>
                        <option value="5">已完成</option>
                        <option value="6">待审核</option>
                    </select>
                </span>

                <span class="fl item-text mt-3 ml-30">交易时间：</span>
                <span class="choose-start-date fl mt-3 ml-10 w200">
                    <input type="text" autocomplete="off" name="start_time" class="date-text choosetime">
                    <i class="date-icon"></i>
                </span>
                <span class="fl item-text mt-3 ml-5"> -</span>
                <span class="choose-start-date fl mt-3 ml-5 w200">
                    <input type="text" autocomplete="off" name="end_time" class="date-text choosetime">
                    <i class="date-icon"></i>
                </span>

                <div class="cfg-header-search">
                    <input type="text" id="searchkey" placeholder="订单号/联系人信息/产品名称" class="search-text">
                    <a href="javascript:;" class="search-btn" onclick="searchKeyword()">搜索</a>
                </div>
            </div>
            <div id="product_grid_panel" class="content-nrt">

            </div>
        </td>
    </tr>
</table>
<script>
    function searchKeyword(){
        var type_id = $.trim($("[name='type_id']").find("option:selected").val());
        var keyword = $.trim($("#searchkey").val());
        var str_time = $.trim($("[name='start_time']").val());
        var end_time = $.trim($("[name='end_time']").val());
        var status = $.trim($("[name='status']").find("option:selected").val());
        keyword = keyword? keyword : '';
        str_time = str_time?str_time:'';
        end_time = end_time?end_time:'';
        status = status?status:'';

        window.product_store.getProxy().setExtraParam('keyword',keyword);
        window.product_store.getProxy().setExtraParam('start_time',str_time);
        window.product_store.getProxy().setExtraParam('end_time',end_time);
        window.product_store.getProxy().setExtraParam('type_id',type_id);
        window.product_store.getProxy().setExtraParam('status',status);
        window.product_store.loadPage(1);
    }
    //日历选择
    $(".choosetime").click(function(){
        WdatePicker({skin:'whyGreen',dateFmt:'yyyy-MM-dd',minDate:'{%y-2}-%M-%d',maxDate: '#{%y}-%M-%d'})
    });
    window.display_mode=1;	//默认显示模式
    window.product_kindid=0;  //默认目的地ID
    Ext.onReady(
        function()
        {
            Ext.tip.QuickTipManager.init();
            $(".btnbox").buttonBox();
            $("#searchkey").focusEffect();
            //产品store
            window.product_store=Ext.create('Ext.data.Store',{

                fields:[
                    'order_id',
                    'ordersn',
                    'productname',
                    'paytime',
                    'status_name',
                    'total_price',
                    'platform_commission',
                    'supplier_commission'
                ],
                proxy:{
                    type:'ajax',
                    api: {
                        read: SITEURL+'ebooking/finance/action/read',  //读取数据的URL
                        update:SITEURL+'ebooking/finance/action/save',
                        destroy:SITEURL+'ebooking/finance/action/delete'
                    },
                    reader:{
                        type: 'json',   //获取数据的格式
                        root: 'lists',
                        totalProperty: 'total'
                    }
                },
                remoteSort:true,
                autoLoad:true,
                pageSize:20,
                listeners:{
                    load:function( store, records, successful, eOpts )
                    {
                        if(!successful){
                            ST.Util.showMsg("{__('norightmsg')}",5,1000);
                        }
                        var pageHtml = ST.Util.page(store.pageSize, store.currentPage, store.getTotalCount(), 10);
                        $("#line_page").html(pageHtml);
                        window.product_grid.doLayout();

                        $(".pageContainer .pagePart a").click(function () {
                            var page = $(this).attr('page');
                            product_store.loadPage(page);
                        });
                    }
                }
            });
            //产品列表
            window.product_grid=Ext.create('Ext.grid.Panel',{
                store:product_store,
                renderTo:'product_grid_panel',
                border:0,
                bodyBorder:0,
                bodyStyle:'border-width:0px',
                scroll:'vertical', //只要垂直滚动条
                bbar: Ext.create('Ext.toolbar.Toolbar', {
                    store: product_store,  //这个和grid用的store一样
                    displayInfo: true,
                    emptyMsg: "",
                    items:[
                        {
                            xtype:'panel',
                            id:'listPagePanel',
                            html:'<div id="line_page"></div>'
                        },
                        {
                            xtype:'combo',
                            fieldLabel:'每页显示数量',
                            width:170,
                            labelAlign:'right',
                            forceSelection:true,
                            value:20,
                            store:{fields:['num'],data:[{num:20},{num:40},{num:60}]},
                            displayField:'num',
                            valueField:'num',
                            listeners:{
                                select:CHOOSE.changeNum
                            }
                        }

                    ],
                    listeners: {
                        single: true,
                        render: function(bar) {
                            var items = this.items;
                            bar.insert(2,Ext.create('Ext.toolbar.Fill'));
                        }
                    }
                }),
                columns:[
                    {
                        text:'订单号',
                        width:'10%',
                        dataIndex:'ordersn',
                        align:'center',
                        menuDisabled:true,
                        border:0,
                        sortable:false,
                        renderer : function(value, metadata,record) {
                            var id = record.get('order_id');
                            var html = "<a class='btn-link' href='javascript:void(0);' onclick=\"view(" + id + ","+value+")\">"+value+"</a>";
                            return html;
                        }
                    },
                    {
                        text:'产品名称',
                        width:'30%',
                        dataIndex:'productname',
                        align:'center',
                        menuDisabled:true,
                        border:0,
                        sortable:false,
                        renderer : function(value, metadata,record) {
                            return value;
                        }
                    },
                    {
                        text: '支付时间',
                        width: '12%',
                        dataIndex: 'paytime',
                        align: 'center',
                        border: 0,
                        sortable: false,
                        menuDisabled:true,
                        renderer : function(value, metadata,record) {
                            return value;
                        }
                    },
                    {
                        text:'订单金额',
                        width:'12%',
                        dataIndex:'total_price',
                        align:'center',
                        menuDisabled:true,
                        border:0,
                        sortable:false,
                        renderer : function(value, metadata,record) {
                            return "{Currency_Tool::symbol()}"+value;
                        }
                    },
                    {
                        text:'平台分佣',
                        width:'12%',
                        dataIndex:'platform_commission',
                        align:'center',
                        menuDisabled:true,
                        border:0,
                        sortable:false,
                        renderer : function(value, metadata,record) {
                            return "{Currency_Tool::symbol()}"+value;
                        }
                    },
                    {
                        text:'供应商收益',
                        width:'12%',
                        dataIndex:'supplier_commission',
                        align:'center',
                        menuDisabled:true,
                        border:0,
                        sortable:false,
                        renderer : function(value, metadata,record) {
                            return "{Currency_Tool::symbol()}"+value;
                        }
                    },
                    {
                        text:'订单状态',
                        width:'12%',
                        dataIndex:'status_name',
                        align:'center',
                        menuDisabled:true,
                        border:0,
                        sortable:false,
                        renderer : function(value, metadata,record) {
                            return value;
                        }
                    }
                ],
                listeners:{
                    boxready:function()
                    {
                        var height=Ext.dom.Element.getViewportHeight();
                        this.maxHeight=height-76;
                        this.doLayout();
                    },
                    afterlayout:function(grid)
                    {
                        var data_height=0;
                        try{
                            data_height=grid.getView().getEl().down('.x-grid-table').getHeight();
                        }catch(e)
                        {
                        }
                        var height=Ext.dom.Element.getViewportHeight();

                        if(data_height>height-76)
                        {
                            window.has_biged=true;
                            grid.height=height-76;
                        }
                        else if(data_height<height-76)
                        {
                            if(window.has_biged)
                            {
                                window.has_biged=false;
                                grid.doLayout();
                            }
                        }
                    }
                },
                plugins: [
                    Ext.create('Ext.grid.plugin.CellEditing', {
                        clicksToEdit:2,
                        listeners:{
                            edit:function(editor, e)
                            {
                                return false;

                            },
                            beforeedit:function(editor,e)
                            {

                            }
                        }
                    })
                ],
                viewConfig:{
                    //enableTextSelection:true
                }
            });
        })
    //查看订单
    function view(id,ordersn)
    {
        var url=SITEURL+"hotel/admin/order/view/{if isset($_GET['menuid'])}menuid/{$_GET['menuid']}/{/if}id/"+id+"/typeid/2";
        ST.Util.addTab('酒店订单：'+ordersn,url,1);

    }
</script>
</body>
</html>
